package main

var cache = make(map[int]int)

func countNumbersWithUniqueDigits(n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return 10
	}
	if v, ok := cache[n]; ok {
		return v
	}
	ret := 9
	for i := 1; i < n; i++ {
		ret = ret * (10 - i)
	}
	ret += countNumbersWithUniqueDigits(n - 1)
	cache[n] = ret
	return ret
}

func main() {
	println(countNumbersWithUniqueDigits(3))
	println(countNumbersWithUniqueDigits(3))
}
